<template>
	<view>
		<view style="padding: 30rpx;">
			<view class="u-flex u-font-weight  " style="color: #FF5D39;margin: 40rpx 0;font-size: 34rpx;">
				<text>{{info.top==0?'免费':info.top==1?'插队':info.top==2 ?'加急':''}}设计	</text>
				—
				<text>{{info.status==6?'已完成':'-待处理'}}</text>

			</view>


			<view class="mode u-margin-bottom-20" v-if="info.status==4">
				<view class="u-flex u-row-between u-margin-bottom-20">
					<view class="$u-type-info">设计总价</view>
					<view class="$u-type-error">￥{{info.designMoney}}</view>
				</view>

				<view class="u-flex u-row-between">
					<view class="$u-type-info">支付金额</view>
					<view class="$u-type-error">￥{{info.payMoney}}</view>
				</view>

			</view>


			<!-- 文件 -->
			<view class="mode u-margin-bottom-20">
				<view class="u-flex u-row-between " v-for="(item,index) in info.dl" :key="index" v-if="item.status">
					<view class="u-flex">
						<u-image src="/static/file.png" width="160" height="160"></u-image>
						<view class="u-margin-left-20">
							<view>设计文件</view>
							<view class="u-margin-top-20">请下载查看哦！</view>
						</view>
					</view>
					
					<u-button size="mini" shape="circle" type="error" @click="look(item)">查看</u-button>
				</view>
			</view>


			<view class="mode">
				<view class="u-flex u-row-between u-row-center">
					<view class="u-font-weight">设计需求</view>
					<view class="$u-type-info">{{info.createTime}}</view>
				</view>
				<view class="u-margin-top-20 u-margin-bottom-20">{{info.remark}}</view>
				<view class="u-flex">
					<view v-for="(item,index) in info.image" :key="index" class="u-margin-right-20">
						<u-image :src="item" width="150" height="150"></u-image>
					</view>
				</view>
			</view>

		</view>



		<view class="bottomFix" v-if="info.status!==6">
			<u-button @click="want_pre" shape="circle" :custom-style="{background:'#FF5D39',color:'#fff'}">
				我要插队</u-button>
		</view>




		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import payway from '@/common/wxpay.js';
	export default {
		data() {
			return {
				id: "",
				info: {},
				buyDesignReferFee: '', //设计组讯飞
				banShare: true
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id
			}


			this.$u.api.Commission().then(res => {
				this.buyDesignReferFee = Number(res.buyDesignReferFee).toFixed(2)
			})
		},
		onShow() {
			this.jiazai()
		},
		methods: {
			look(item){
				uni.navigateTo({
					url:"./fileDetail?item="+JSON.stringify(item)  
				})
			},
			want_pre() {
				this.$u.post('/indent/jumpQueue', {
					order_id: this.id
				}).then(res => {
					if (!Array.isArray(res)) {
						var packages = res.package;
						var {
							noncestr,
							timestamp,
							signtype,
							paysign
						} = res;
						payway.wx(timestamp, noncestr, packages, signtype, paysign).then(res => {
							this.$refs.uToast.show({
								title: '插队成功',
								type: 'success',
								back: true
							})
							this.jiazai()
						}).catch(err => {
							uni.navigateBack({

							})
						})
					} else {
						this.$refs.uToast.show({
							title: '插队成功',
							type: 'success',
							back: true
						})

						this.jiazai()

					}


				}).catch(err => {

				})

			},
			upload(item) {
				uni.showModal({
					title: "请复制路径至浏览器下载",
					content: "" + item,
					confirmText: "复制",
					success: (res) => {
						if (res.confirm) {
							uni.setClipboardData({
								data: item,
							})
						}
					}
				})
			},
			jiazai() {
				this.$u.post('/indent/orderDetail', {
					order_id: this.id
				}).then(res => {
					this.info = res
				}).catch(err => {

				})
			},
			buy() {
				this.$u.post('/indent/pay', {
					order_id: this.id
				}).then(res => {
					var packages = res.package;
					var {
						noncestr,
						timestamp,
						signtype,
						paysign
					} = res
					payway.wx(timestamp, noncestr, packages, signtype, paysign).then(res => {
						this.$refs.uToast.show({
							title: '支付成功',
							type: 'success',
							back: true
						})

					}).catch(err => {

					})

				}).catch(err => {

				})
			},
			kanjia() {
				uni.navigateTo({
					url: "./kanjia?id=" + this.id
				})
			},
			apply() {
				uni.navigateTo({
					url: "./applyChange?id=" + this.id + '&changeNum=' + this.info.changeNum
				})
			}

		}
	}
</script>

<style>
	.bg {
		background: #FF5D39;
		padding: 20rpx 40rpx;
		border-radius: 20rpx;
		color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;


	}
</style>
